home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Devices.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  28KB  |  831 lines

  1. /*
  2.      File:        Devices.h
  3.  
  4.      Contains:    Device Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5 and 8
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __DEVICES__
  19. #define __DEVICES__
  20.  
  21. #ifndef __OSUTILS__
  22. #include <OSUtils.h>
  23. #endif
  24. #ifndef __FILES__
  25. #include <Files.h>
  26. #endif
  27. #ifndef __QUICKDRAW__
  28. #include <Quickdraw.h>
  29. #endif
  30. #ifndef __EVENTS__
  31. #include <Events.h>
  32. #endif
  33. #if FOR_SYSTEM7_ONLY
  34. #ifndef __DIALOGS__
  35. #include <Dialogs.h>
  36. #endif
  37. #endif
  38. #ifndef __KERNEL__
  39. #include <Kernel.h>
  40. #endif
  41. #ifndef __NAMEREGISTRY__
  42. #include <NameRegistry.h>
  43. #endif
  44. #ifndef __CODEFRAGMENTS__
  45. #include <CodeFragments.h>
  46. #endif
  47. #ifndef __DRIVERFAMILYMATCHING__
  48. #include <DriverFamilyMatching.h>
  49. #endif
  50. #ifndef __IOITERATOR__
  51. #include <IOIterator.h>
  52. #endif
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57.  
  58. #if PRAGMA_IMPORT_SUPPORTED
  59. #pragma import on
  60. #endif
  61.  
  62. #if PRAGMA_ALIGN_SUPPORTED
  63. #pragma options align=mac68k
  64. #endif
  65.  
  66. /* Values of the 'message' parameter to a Chooser device package */
  67.  
  68. enum {
  69.     chooserInitMsg                = 11,                            /* the user selected this device package */
  70.     newSelMsg                    = 12,                            /* the user made new device selections */
  71.     fillListMsg                    = 13,                            /* fill the device list with choices */
  72.     getSelMsg                    = 14,                            /* mark one or more choices as selected */
  73.     selectMsg                    = 15,                            /* the user made a selection */
  74.     deselectMsg                    = 16,                            /* the user canceled a selection */
  75.     terminateMsg                = 17,                            /* allows device package to clean up */
  76.     buttonMsg                    = 19                            /* the user selected a button */
  77. };
  78.  
  79. /* Values of the 'caller' parameter to a Chooser device package */
  80.  
  81. enum {
  82.     chooserID                    = 1
  83. };
  84.  
  85. /* Values of the 'message' parameter to a Control Panel 'cdev' */
  86.  
  87. enum {
  88.     initDev                        = 0,                            /*Time for cdev to initialize itself*/
  89.     hitDev                        = 1,                            /*Hit on one of my items*/
  90.     closeDev                    = 2,                            /*Close yourself*/
  91.     nulDev                        = 3,                            /*Null event*/
  92.     updateDev                    = 4,                            /*Update event*/
  93.     activDev                    = 5,                            /*Activate event*/
  94.     deactivDev                    = 6,                            /*Deactivate event*/
  95.     keyEvtDev                    = 7,                            /*Key down/auto key*/
  96.     macDev                        = 8,                            /*Decide whether or not to show up*/
  97.     undoDev                        = 9,
  98.     cutDev                        = 10,
  99.     copyDev                        = 11,
  100.     pasteDev                    = 12,
  101.     clearDev                    = 13,
  102.     cursorDev                    = 14
  103. };
  104.  
  105. /* Special values a Control Panel 'cdev' can return */
  106.  
  107. enum {
  108.     cdevGenErr                    = -1,                            /*General error; gray cdev w/o alert*/
  109.     cdevMemErr                    = 0,                            /*Memory shortfall; alert user please*/
  110.     cdevResErr                    = 1,                            /*Couldn't get a needed resource; alert*/
  111.     cdevUnset                    = 3                                /* cdevValue is initialized to this*/
  112. };
  113.  
  114. /* Values of the 'message' parameter to a Monitor 'mntr' */
  115.  
  116. enum {
  117.     initMsg                        = 1,                            /*initialization*/
  118.     okMsg                        = 2,                            /*user clicked OK button*/
  119.     cancelMsg                    = 3,                            /*user clicked Cancel button*/
  120.     hitMsg                        = 4,                            /*user clicked control in Options dialog*/
  121.     nulMsg                        = 5,                            /*periodic event*/
  122.     updateMsg                    = 6,                            /*update event*/
  123.     activateMsg                    = 7,                            /*not used*/
  124.     deactivateMsg                = 8,                            /*not used*/
  125.     keyEvtMsg                    = 9,                            /*keyboard event*/
  126.     superMsg                    = 10,                            /*show superuser controls*/
  127.     normalMsg                    = 11,                            /*show only normal controls*/
  128.     startupMsg                    = 12                            /*code has been loaded*/
  129. };
  130.  
  131. /* control codes for DeskAccessories */
  132.  
  133. enum {
  134.     goodbye                        = -1,                            /* heap being reinitialized */
  135.     killCode                    = 1,                            /* KillIO requested */
  136.     accEvent                    = 64,                            /* handle an event */
  137.     accRun                        = 65,                            /* time for periodic action */
  138.     accCursor                    = 66,                            /* change cursor shape */
  139.     accMenu                        = 67,                            /* handle menu item */
  140.     accUndo                        = 68,                            /* handle undo command */
  141.     accCut                        = 70,                            /* handle cut command */
  142.     accCopy                        = 71,                            /* handle copy command */
  143.     accPaste                    = 72,                            /* handle paste command */
  144.     accClear                    = 73                            /* handle clear command */
  145. };
  146.  
  147. /* Control/Status Call Codes */
  148.  
  149. enum {
  150.     drvStsCode                    = 8,                            /* status call code for drive status */
  151.     ejectCode                    = 7,                            /* control call eject code */
  152.     tgBuffCode                    = 8                                /* set tag buffer code */
  153. };
  154.  
  155. /* miscellaneous Device Manager constants */
  156.  
  157. enum {
  158.     ioInProgress                = 1,                            /* predefined value of ioResult while I/O is pending */
  159.     aRdCmd                        = 2,                            /* low byte of ioTrap for Read calls */
  160.     aWrCmd                        = 3,                            /* low byte of ioTrap for Write calls */
  161.     asyncTrpBit                    = 10,                            /* trap word modifier */
  162.     noQueueBit                    = 9                                /* trap word modifier */
  163. };
  164.  
  165. /* flags used in the driver header and device control entry */
  166.  
  167. enum {
  168.     dReadEnable                    = 0,                            /* set if driver responds to read requests */
  169.     dWritEnable                    = 1,                            /* set if driver responds to write requests */
  170.     dCtlEnable                    = 2,                            /* set if driver responds to control requests */
  171.     dStatEnable                    = 3,                            /* set if driver responds to status requests */
  172.     dNeedGoodBye                = 4,                            /* set if driver needs time for performing periodic tasks */
  173.     dNeedTime                    = 5,                            /* set if driver needs time for performing periodic tasks */
  174.     dNeedLock                    = 6,                            /* set if driver must be locked in memory as soon as it is opened */
  175.     dNeedLockMask                = 0x4000,                        /* set if driver must be locked in memory as soon as it is opened */
  176.     dNeedTimeMask                = 0x2000,                        /* set if driver needs time for performing periodic tasks */
  177.     dNeedGoodByeMask            = 0x1000,                        /* set if driver needs to be called before the application heap is initialized */
  178.     dStatEnableMask                = 0x0800,                        /* set if driver responds to status requests */
  179.     dCtlEnableMask                = 0x0400,                        /* set if driver responds to control requests */
  180.     dWritEnableMask                = 0x0200,                        /* set if driver responds to write requests */
  181.     dReadEnableMask                = 0x0100                        /* set if driver responds to read requests */
  182. };
  183.  
  184. /* run-time flags used in the device control entry */
  185.  
  186. enum {
  187.     dOpened                        = 5,                            /* driver is open */
  188.     dRAMBased                    = 6,                            /* dCtlDriver is a handle (1) or pointer (0) */
  189.     drvrActive                    = 7,                            /* driver is currently processing a request */
  190.     drvrActiveMask                = 0x0080,                        /* driver is currently processing a request */
  191.     dRAMBasedMask                = 0x0040,                        /* dCtlDriver is a handle (1) or pointer (0) */
  192.     dOpenedMask                    = 0x0020                        /* driver is open */
  193. };
  194.  
  195. struct DRVRHeader {
  196.     short                             drvrFlags;
  197.     short                             drvrDelay;
  198.     short                             drvrEMask;
  199.     short                             drvrMenu;
  200.     short                             drvrOpen;
  201.     short                             drvrPrime;
  202.     short                             drvrCtl;
  203.     short                             drvrStatus;
  204.     short                             drvrClose;
  205.     unsigned char                     drvrName[1];
  206. };
  207. typedef struct DRVRHeader DRVRHeader;
  208.  
  209. typedef DRVRHeader *DRVRHeaderPtr;
  210. typedef DRVRHeaderPtr *DRVRHeaderHandle;
  211. #if FOR_SYSTEM7_ONLY
  212. struct DCtlEntry {
  213.     Ptr                             dCtlDriver;
  214.     short                             dCtlFlags;
  215.     QHdr                             dCtlQHdr;
  216.     long                             dCtlPosition;
  217.     Handle                             dCtlStorage;
  218.     short                             dCtlRefNum;
  219.     long                             dCtlCurTicks;
  220.     WindowPtr                         dCtlWindow;
  221.     short                             dCtlDelay;
  222.     short                             dCtlEMask;
  223.     short                             dCtlMenu;
  224. };
  225. typedef struct DCtlEntry DCtlEntry;
  226.  
  227. #else
  228. struct DCtlEntry {
  229.     Ptr                             dCtlDriver;
  230.     short                             dCtlFlags;
  231.     QHdr                             dCtlQHdr;
  232.     long                             dCtlPosition;
  233.     Handle                             dCtlStorage;
  234.     short                             dCtlRefNum;
  235.     long                             dCtlCurTicks;
  236.     Ptr                             dCtlWindow;
  237.     short                             dCtlDelay;
  238.     short                             dCtlEMask;
  239.     short                             dCtlMenu;
  240. };
  241. typedef struct DCtlEntry DCtlEntry;
  242.  
  243. #endif
  244. typedef DCtlEntry *DCtlPtr;
  245. typedef DCtlPtr *DCtlHandle;
  246. #if FOR_SYSTEM7_ONLY
  247. struct AuxDCE {
  248.     Ptr                             dCtlDriver;
  249.     short                             dCtlFlags;
  250.     QHdr                             dCtlQHdr;
  251.     long                             dCtlPosition;
  252.     Handle                             dCtlStorage;
  253.     short                             dCtlRefNum;
  254.     long                             dCtlCurTicks;
  255.     GrafPtr                         dCtlWindow;
  256.     short                             dCtlDelay;
  257.     short                             dCtlEMask;
  258.     short                             dCtlMenu;
  259.     SInt8                             dCtlSlot;
  260.     SInt8                             dCtlSlotId;
  261.     long                             dCtlDevBase;
  262.     Ptr                             dCtlOwner;
  263.     SInt8                             dCtlExtDev;
  264.     SInt8                             fillByte;
  265.     UInt32                             dCtlNodeID;
  266. };
  267. typedef struct AuxDCE AuxDCE;
  268.  
  269. typedef AuxDCE *AuxDCEPtr;
  270. typedef AuxDCEPtr *AuxDCEHandle;
  271. #else
  272. struct AuxDCE {
  273.     Ptr                             dCtlDriver;
  274.     short                             dCtlFlags;
  275.     QHdr                             dCtlQHdr;
  276.     long                             dCtlPosition;
  277.     Handle                             dCtlStorage;
  278.     short                             dCtlRefNum;
  279.     long                             dCtlCurTicks;
  280.     Ptr                             dCtlWindow;
  281.     short                             dCtlDelay;
  282.     short                             dCtlEMask;
  283.     short                             dCtlMenu;
  284.     SInt8                             dCtlSlot;
  285.     SInt8                             dCtlSlotId;
  286.     long                             dCtlDevBase;
  287.     Ptr                             dCtlOwner;
  288.     SInt8                             dCtlExtDev;
  289.     SInt8                             fillByte;
  290.     UInt32                             dCtlNodeID;
  291. };
  292. typedef struct AuxDCE AuxDCE;
  293.  
  294. typedef AuxDCE *AuxDCEPtr;
  295. typedef AuxDCEPtr *AuxDCEHandle;
  296. #endif
  297. /*    The NDRV Driver IO Entry Point and Commands */
  298. typedef UInt16 UnitNumber;
  299. typedef UInt32 DriverOpenCount;
  300. typedef SInt16 DriverRefNum;
  301. typedef SInt16 DriverFlags;
  302. typedef UInt32 IOCommandCode;
  303.  
  304. enum {
  305.     kOpenCommand                = 0,
  306.     kCloseCommand                = 1,
  307.     kReadCommand                = 2,
  308.     kWriteCommand                = 3,
  309.     kControlCommand                = 4,
  310.     kStatusCommand                = 5,
  311.     kKillIOCommand                = 6,
  312.     kInitializeCommand            = 7,                            /* init driver and device*/
  313.     kFinalizeCommand            = 8,                            /* shutdown driver and device*/
  314.     kReplaceCommand                = 9,                            /* replace an old driver*/
  315.     kSupersededCommand            = 10                            /* prepare to be replaced by a new driver*/
  316. };
  317.  
  318. typedef struct OpaqueIOCommandID* IOCommandID;
  319. typedef UInt32 IOCommandKind;
  320.  
  321. enum {
  322.     kSynchronousIOCommandKind    = 0x00000001,
  323.     kAsynchronousIOCommandKind    = 0x00000002,
  324.     kImmediateIOCommandKind        = 0x00000004
  325. };
  326.  
  327. struct DriverInitInfo {
  328.     DriverRefNum                     refNum;
  329.     RegEntryRef                     deviceEntry;
  330. };
  331. typedef struct DriverInitInfo DriverInitInfo;
  332.  
  333. typedef DriverInitInfo *DriverInitInfoPtr;
  334. typedef DriverInitInfo DriverReplaceInfo;
  335. typedef DriverInitInfo *DriverReplaceInfoPtr;
  336. struct DriverFinalInfo {
  337.     DriverRefNum                     refNum;
  338.     RegEntryRef                     deviceEntry;
  339. };
  340. typedef struct DriverFinalInfo DriverFinalInfo;
  341.  
  342. typedef DriverFinalInfo *DriverFinalInfoPtr;
  343. typedef DriverFinalInfo DriverSupersededInfo;
  344. typedef DriverFinalInfo *DriverSupersededInfoPtr;
  345. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  346. /* Contents are command specific*/
  347. union IOCommandContents {
  348.     ParmBlkPtr                         pb;
  349.     DriverInitInfoPtr                 initialInfo;
  350.     DriverFinalInfoPtr                 finalInfo;
  351.     DriverReplaceInfoPtr             replaceInfo;
  352.     DriverSupersededInfoPtr         supersededInfo;
  353. };
  354. typedef union IOCommandContents IOCommandContents;
  355.  
  356. #else
  357. struct IOParam {
  358.     QElemPtr                         qLink;                        /*queue link in header*/
  359.     short                             qType;                        /*type byte for safety check*/
  360.     short                             ioTrap;                        /*FS: the Trap*/
  361.     Ptr                             ioCmdAddr;                    /*FS: address to dispatch to*/
  362.     ProcPtr                         ioCompletion;                /*completion routine addr (0 for synch calls)*/
  363.     OSErr                             ioResult;                    /*result code*/
  364.     StringPtr                         ioNamePtr;                    /*ptr to Vol:FileName string*/
  365.     short                             ioVRefNum;                    /*volume refnum (DrvNum for Eject and MountVol)*/
  366.     short                             ioRefNum;                    /*refNum for I/O operation*/
  367.     SInt8                             ioVersNum;                    /*version number*/
  368.     SInt8                             ioPermssn;                    /*Open: permissions (byte)*/
  369.     Ptr                             ioMisc;                        /*Rename: new name (GetEOF,SetEOF: logical end of file) (Open: optional ptr to buffer) (SetFileType: new type)*/
  370.     Ptr                             ioBuffer;                    /*data buffer Ptr*/
  371.     long                             ioReqCount;                    /*requested byte count; also = ioNewDirID*/
  372.     long                             ioActCount;                    /*actual byte count completed*/
  373.     short                             ioPosMode;                    /*initial file positioning*/
  374.     long                             ioPosOffset;                /*file position offset*/
  375. };
  376. typedef struct IOParam IOParam;
  377.  
  378. typedef IOParam *IOParamPtr;
  379. struct CntrlParam {
  380.     QElemPtr                         qLink;                        /*queue link in header*/
  381.     short                             qType;                        /*type byte for safety check*/
  382.     short                             ioTrap;                        /*FS: the Trap*/
  383.     Ptr                             ioCmdAddr;                    /*FS: address to dispatch to*/
  384.     ProcPtr                         ioCompletion;                /*completion routine addr (0 for synch calls)*/
  385.     OSErr                             ioResult;                    /*result code*/
  386.     StringPtr                         ioNamePtr;                    /*ptr to Vol:FileName string*/
  387.     short                             ioVRefNum;                    /*volume refnum (DrvNum for Eject and MountVol)*/
  388.     short                             ioCRefNum;                    /*refNum for I/O operation*/
  389.     short                             csCode;                        /*word for control status code*/
  390.     short                             csParam[11];                /*operation-defined parameters*/
  391. };
  392. typedef struct CntrlParam CntrlParam;
  393.  
  394. typedef CntrlParam *CntrlParamPtr;
  395. union ParamBlockRec {
  396.     IOParam                         ioParam;
  397.     CntrlParam                         cntrlParam;
  398. };
  399. typedef union ParamBlockRec ParamBlockRec;
  400.  
  401. typedef ParamBlockRec *ParmBlkPtr;
  402. union IOCommandContents {
  403.     ParmBlkPtr                         pb;
  404.     DriverInitInfoPtr                 initialInfo;
  405.     DriverFinalInfoPtr                 finalInfo;
  406.     DriverReplaceInfoPtr             replaceInfo;
  407.     DriverSupersededInfoPtr         supersededInfo;
  408. };
  409. typedef union IOCommandContents IOCommandContents;
  410.  
  411. #endif
  412. typedef OSErr (*DriverEntryPointPtr)(AddressSpaceID SpaceID, IOCommandID CommandID, IOCommandContents Contents, IOCommandCode Code, IOCommandKind Kind);
  413. /* Record to describe a file-based driver candidate */
  414. struct FileBasedDriverRecord {
  415.     FSSpec                             theSpec;                    /* file specification*/
  416.     DriverType                         theType;                    /* nameInfoStr + version number*/
  417.     Boolean                         compatibleProp;                /* true if matched using a compatible name*/
  418.     UInt8                             pad[3];                        /* alignment*/
  419. };
  420. typedef struct FileBasedDriverRecord FileBasedDriverRecord;
  421.  
  422. typedef FileBasedDriverRecord *FileBasedDriverRecordPtr;
  423. /* Driver Loader API */
  424. #define DECLARE_DRIVERDESCRIPTION(N_ADDITIONAL_SERVICES)\
  425.         struct {\
  426.             DriverDescription    fixed;\
  427.             DriverServiceInfo    additional_service[N_ADDITIONAL_SERVICES-1];\
  428.         };
  429.  
  430. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  431. extern SInt16 HigherDriverVersion(NumVersion *driverVersion1, NumVersion *driverVersion2);
  432.  
  433. extern OSErr VerifyFragmentAsDriver(CFragConnectionID fragmentConnID, DriverEntryPointPtr *fragmentMain, DriverDescriptionPtr *driverDesc);
  434.  
  435. extern OSErr GetDriverMemoryFragment(Ptr memAddr, long length, ConstStr63Param fragName, CFragConnectionID *fragmentConnID, DriverEntryPointPtr *fragmentMain, DriverDescriptionPtr *driverDesc);
  436.  
  437. extern OSErr GetDriverDiskFragment(FSSpecPtr fragmentSpec, CFragConnectionID *fragmentConnID, DriverEntryPointPtr *fragmentMain, DriverDescriptionPtr *driverDesc);
  438.  
  439. #if FOR_SYSTEM7_ONLY
  440. extern OSErr InstallDriverFromFragment(CFragConnectionID fragmentConnID, RegEntryID *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  441.  
  442. extern OSErr InstallDriverFromFile(FSSpecPtr fragmentSpec, RegEntryID *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  443.  
  444. extern OSErr InstallDriverFromMemory(Ptr memory, long length, ConstStr63Param fragName, RegEntryID *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  445.  
  446. extern OSErr InstallDriverFromDisk(Ptr theDriverName, RegEntryID *theDevice, UnitNumber theBeginningUnit, UnitNumber theEndingUnit, DriverRefNum *theRefNum);
  447.  
  448. extern OSErr FindDriversForDevice(RegEntryID *device, FSSpec *fragmentSpec, DriverDescription *fileDriverDesc, Ptr *memAddr, long *length, StringPtr fragName, DriverDescription *memDriverDesc);
  449.  
  450. extern OSErr FindDriverCandidates(RegEntryID *deviceID, Ptr *propBasedDriver, RegPropertyValueSize *propBasedDriverSize, StringPtr deviceName, DriverType *propBasedDriverType, Boolean *gotPropBasedDriver, FileBasedDriverRecordPtr fileBasedDrivers, ItemCount *nFileBasedDrivers);
  451.  
  452. extern OSErr ScanDriverCandidates(RegEntryID *deviceID, FileBasedDriverRecordPtr fileBasedDrivers, ItemCount nFileBasedDrivers, FileBasedDriverRecordPtr matchingDrivers, ItemCount *nMatchingDrivers);
  453.  
  454. extern OSErr GetDriverForDevice(RegEntryID *device, CFragConnectionID *fragmentConnID, DriverEntryPointPtr *fragmentMain, DriverDescriptionPtr *driverDesc);
  455.  
  456. extern OSErr InstallDriverForDevice(RegEntryID *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  457.  
  458. extern OSErr GetDriverInformation(DriverRefNum refNum, UnitNumber *unitNum, DriverFlags *flags, DriverOpenCount *count, StringPtr name, RegEntryID *device, CFragSystem7Locator *driverLoadLocation, CFragConnectionID *fragmentConnID, DriverEntryPointPtr *fragmentMain, DriverDescription *driverDesc);
  459.  
  460. #else
  461. extern OSErr InstallDriverFromFragment(CFragConnectionID fragmentConnID, RegEntryRef *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  462.  
  463. extern OSErr InstallDriverFromFile(FSSpecPtr fragmentSpec, RegEntryRef *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  464.  
  465. extern OSErr InstallDriverFromMemory(Ptr memory, long length, ConstStr63Param fragName, RegEntryRef *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  466.  
  467. extern OSErr InstallDriverFromDisk(Ptr theDriverName, RegEntryRef *theDevice, UnitNumber theBeginningUnit, UnitNumber theEndingUnit, DriverRefNum *theRefNum);
  468.  
  469. extern OSErr FindDriversForDevice(RegEntryRef *device, FSSpec *fragmentSpec, DriverDescription *fileDriverDesc, Ptr *memAddr, long *length, StringPtr fragName, DriverDescription *memDriverDesc);
  470.  
  471. extern OSErr FindDriverCandidates(RegEntryRef *deviceID, Ptr *propBasedDriver, UInt32 *propBasedDriverSize, StringPtr deviceName, DriverType *propBasedDriverType, Boolean *gotPropBasedDriver, FileBasedDriverRecordPtr fileBasedDrivers, ItemCount *nFileBasedDrivers);
  472.  
  473. extern OSErr ScanDriverCandidates(RegEntryRef *deviceID, FileBasedDriverRecordPtr fileBasedDrivers, ItemCount nFileBasedDrivers, FileBasedDriverRecordPtr matchingDrivers, ItemCount *nMatchingDrivers);
  474.  
  475. extern OSErr GetDriverForDevice(RegEntryRef *device, CFragConnectionID *fragmentConnID, DriverEntryPointPtr *fragmentMain, DriverDescriptionPtr *driverDesc);
  476.  
  477. extern OSErr InstallDriverForDevice(RegEntryRef *device, UnitNumber beginningUnit, UnitNumber endingUnit, DriverRefNum *refNum);
  478.  
  479. #endif
  480. extern OSErr SetDriverClosureMemory(CFragConnectionID fragmentConnID, Boolean holdDriverMemory);
  481.  
  482. extern OSErr ReplaceDriverWithFragment(DriverRefNum theRefNum, CFragConnectionID fragmentConnID);
  483.  
  484. extern OSErr OpenInstalledDriver(DriverRefNum refNum, SInt8 ioPermission);
  485.  
  486. extern OSErr RenameDriver(DriverRefNum refNum, StringPtr newDriverName);
  487.  
  488. extern OSErr RemoveDriver(DriverRefNum refNum, Boolean immediate);
  489.  
  490. extern OSErr LookupDrivers(UnitNumber beginningUnit, UnitNumber endingUnit, Boolean emptyUnits, ItemCount *returnedRefNums, DriverRefNum *refNums);
  491.  
  492. extern UnitNumber HighestUnitNumber(void );
  493.  
  494. extern OSErr DriverGestaltOn(DriverRefNum refNum);
  495.  
  496. extern OSErr DriverGestaltOff(DriverRefNum refNum);
  497.  
  498. extern Boolean DriverGestaltIsOn(DriverFlags flags);
  499.  
  500. #endif
  501. #if !OLDROUTINELOCATIONS
  502. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  503.  
  504. #if GENERATING68K && !GENERATINGCFM
  505. #pragma parameter __D0 PBOpenSync(__A0)
  506. #endif
  507. extern pascal OSErr PBOpenSync(ParmBlkPtr paramBlock)
  508.  ONEWORDINLINE(0xA000);
  509.  
  510.  
  511. #if GENERATING68K && !GENERATINGCFM
  512. #pragma parameter __D0 PBOpenAsync(__A0)
  513. #endif
  514. extern pascal OSErr PBOpenAsync(ParmBlkPtr paramBlock)
  515.  ONEWORDINLINE(0xA400);
  516.  
  517.  
  518. #if GENERATING68K && !GENERATINGCFM
  519. #pragma parameter __D0 PBOpenImmed(__A0)
  520. #endif
  521. extern pascal OSErr PBOpenImmed(ParmBlkPtr paramBlock)
  522.  ONEWORDINLINE(0xA200);
  523.  
  524.  
  525. #if GENERATING68K && !GENERATINGCFM
  526. #pragma parameter __D0 PBCloseSync(__A0)
  527. #endif
  528. extern pascal OSErr PBCloseSync(ParmBlkPtr paramBlock)
  529.  ONEWORDINLINE(0xA001);
  530.  
  531.  
  532. #if GENERATING68K && !GENERATINGCFM
  533. #pragma parameter __D0 PBCloseAsync(__A0)
  534. #endif
  535. extern pascal OSErr PBCloseAsync(ParmBlkPtr paramBlock)
  536.  ONEWORDINLINE(0xA401);
  537.  
  538.  
  539. #if GENERATING68K && !GENERATINGCFM
  540. #pragma parameter __D0 PBCloseImmed(__A0)
  541. #endif
  542. extern pascal OSErr PBCloseImmed(ParmBlkPtr paramBlock)
  543.  ONEWORDINLINE(0xA201);
  544.  
  545.  
  546. #if GENERATING68K && !GENERATINGCFM
  547. #pragma parameter __D0 PBReadSync(__A0)
  548. #endif
  549. extern pascal OSErr PBReadSync(ParmBlkPtr paramBlock)
  550.  ONEWORDINLINE(0xA002);
  551.  
  552.  
  553. #if GENERATING68K && !GENERATINGCFM
  554. #pragma parameter __D0 PBReadAsync(__A0)
  555. #endif
  556. extern pascal OSErr PBReadAsync(ParmBlkPtr paramBlock)
  557.  ONEWORDINLINE(0xA402);
  558.  
  559.  
  560. #if GENERATING68K && !GENERATINGCFM
  561. #pragma parameter __D0 PBReadImmed(__A0)
  562. #endif
  563. extern pascal OSErr PBReadImmed(ParmBlkPtr paramBlock)
  564.  ONEWORDINLINE(0xA202);
  565.  
  566.  
  567. #if GENERATING68K && !GENERATINGCFM
  568. #pragma parameter __D0 PBWriteSync(__A0)
  569. #endif
  570. extern pascal OSErr PBWriteSync(ParmBlkPtr paramBlock)
  571.  ONEWORDINLINE(0xA003);
  572.  
  573.  
  574. #if GENERATING68K && !GENERATINGCFM
  575. #pragma parameter __D0 PBWriteAsync(__A0)
  576. #endif
  577. extern pascal OSErr PBWriteAsync(ParmBlkPtr paramBlock)
  578.  ONEWORDINLINE(0xA403);
  579.  
  580.  
  581. #if GENERATING68K && !GENERATINGCFM
  582. #pragma parameter __D0 PBWriteImmed(__A0)
  583. #endif
  584. extern pascal OSErr PBWriteImmed(ParmBlkPtr paramBlock)
  585.  ONEWORDINLINE(0xA203);
  586.  
  587. extern pascal void AddDrive(short drvrRefNum, short drvNum, DrvQElPtr qEl);
  588.  
  589. #endif
  590. extern pascal QHdrPtr GetDrvQHdr(void )
  591.  THREEWORDINLINE(0x2EBC, 0x0000, 0x0308);
  592.  
  593. #endif
  594. /* Control Panel Default Proc */
  595. #if FOR_SYSTEM7_ONLY
  596. typedef pascal long (*ControlPanelDefProcPtr)(short message, short item, short numItems, short cPanelID, EventRecord *theEvent, long cdevValue, DialogPtr cpDialog);
  597.  
  598. #if GENERATINGCFM
  599. typedef UniversalProcPtr ControlPanelDefUPP;
  600. #else
  601. typedef ControlPanelDefProcPtr ControlPanelDefUPP;
  602. #endif
  603.  
  604. enum {
  605.     uppControlPanelDefProcInfo = kPascalStackBased
  606.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  607.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  608.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  609.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  610.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  611.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(EventRecord *)))
  612.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(long)))
  613.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DialogPtr)))
  614. };
  615.  
  616. #if GENERATINGCFM
  617. #define NewControlPanelDefProc(userRoutine)        \
  618.         (ControlPanelDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlPanelDefProcInfo, GetCurrentArchitecture())
  619. #else
  620. #define NewControlPanelDefProc(userRoutine)        \
  621.         ((ControlPanelDefUPP) (userRoutine))
  622. #endif
  623.  
  624. #if GENERATINGCFM
  625. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  626.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlPanelDefProcInfo, (message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  627. #else
  628. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  629.         (*(userRoutine))((message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  630. #endif
  631. #endif
  632. extern pascal DCtlHandle GetDCtlEntry(short refNum);
  633.  
  634. /*
  635.     SetChooserAlert used to simply set a bit in a low-mem global
  636.     to tell the Chooser not to display its warning message when
  637.     the printer is changed. However, under MultiFinder and System 7,
  638.     this low-mem is swapped out when a layer change occurs, and the
  639.     Chooser never sees the change. It is obsolete, and completely
  640.     unsupported on the PowerPC. 68K apps can still call it if they
  641.     wish.
  642.     
  643. */
  644. #if OLDROUTINENAMES && !GENERATINGCFM
  645. extern pascal Boolean SetChooserAlert(Boolean f);
  646.  
  647. #endif
  648.  
  649. #if GENERATING68K && !GENERATINGCFM
  650. #pragma parameter __D0 DriverInstall(__A0, __D0)
  651. #endif
  652. extern pascal OSErr DriverInstall(DRVRHeaderPtr drvrPtr, short refNum)
  653.  ONEWORDINLINE(0xA03D);
  654.  
  655.  
  656. #if GENERATING68K && !GENERATINGCFM
  657. #pragma parameter __D0 DriverInstallReserveMem(__A0, __D0)
  658. #endif
  659. extern pascal OSErr DriverInstallReserveMem(DRVRHeaderPtr drvrPtr, short refNum)
  660.  ONEWORDINLINE(0xA43D);
  661.  
  662. /*
  663.   Note: DrvrInstall() is no longer supported, becuase it never really worked anyways.
  664.           There will soon be a DriverInstall() which does the right thing.
  665.  
  666.         DrvrRemove has been renamed to DriverRemove.  But, InterfaceLib for PowerPC
  667.         still exports DrvrRemove, so a macro is used to map the new name to old.
  668.  
  669. */
  670.  
  671. #if GENERATING68K && !GENERATINGCFM
  672. #pragma parameter __D0 DrvrRemove(__D0)
  673. #endif
  674. extern pascal OSErr DrvrRemove(short refNum)
  675.  ONEWORDINLINE(0xA03E);
  676.  
  677. #define DriverRemove(refNum) DrvrRemove(refNum)
  678. /*
  679.     Shim mechnanism only exist in Copland world.  A Shim is a translation layer
  680.     and looks like a DRVR. 
  681. */
  682. typedef pascal OSStatus (*ShimEntryPoint)(Ptr paramBlock, Ptr refcon);
  683. extern pascal OSStatus DriverInstallShim(DRVRHeaderPtr drvrPtr, ShimEntryPoint shim, short refNum, void *refcon);
  684.  
  685. extern pascal OSStatus DriverRemoveShim(short refNum);
  686.  
  687. extern pascal OSStatus DriverReturnShimRefcon(short refNum, void **refcon);
  688.  
  689. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  690. extern OSErr IOShimCommandIsComplete(ParmBlkPtr thePB, OSErr result);
  691.  
  692. #endif
  693. extern pascal OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum);
  694.  
  695. extern pascal OSErr CloseDriver(short refNum);
  696.  
  697. extern pascal OSErr Control(short refNum, short csCode, const void *csParamPtr);
  698.  
  699. extern pascal OSErr Status(short refNum, short csCode, void *csParamPtr);
  700.  
  701. extern pascal OSErr KillIO(short refNum);
  702.  
  703. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  704.  
  705. #if GENERATING68K && !GENERATINGCFM
  706. #pragma parameter __D0 PBControlSync(__A0)
  707. #endif
  708. extern pascal OSErr PBControlSync(ParmBlkPtr paramBlock)
  709.  ONEWORDINLINE(0xA004);
  710.  
  711.  
  712. #if GENERATING68K && !GENERATINGCFM
  713. #pragma parameter __D0 PBControlAsync(__A0)
  714. #endif
  715. extern pascal OSErr PBControlAsync(ParmBlkPtr paramBlock)
  716.  ONEWORDINLINE(0xA404);
  717.  
  718.  
  719. #if GENERATING68K && !GENERATINGCFM
  720. #pragma parameter __D0 PBControlImmed(__A0)
  721. #endif
  722. extern pascal OSErr PBControlImmed(ParmBlkPtr paramBlock)
  723.  ONEWORDINLINE(0xA204);
  724.  
  725.  
  726. #if GENERATING68K && !GENERATINGCFM
  727. #pragma parameter __D0 PBStatusSync(__A0)
  728. #endif
  729. extern pascal OSErr PBStatusSync(ParmBlkPtr paramBlock)
  730.  ONEWORDINLINE(0xA005);
  731.  
  732.  
  733. #if GENERATING68K && !GENERATINGCFM
  734. #pragma parameter __D0 PBStatusAsync(__A0)
  735. #endif
  736. extern pascal OSErr PBStatusAsync(ParmBlkPtr paramBlock)
  737.  ONEWORDINLINE(0xA405);
  738.  
  739.  
  740. #if GENERATING68K && !GENERATINGCFM
  741. #pragma parameter __D0 PBStatusImmed(__A0)
  742. #endif
  743. extern pascal OSErr PBStatusImmed(ParmBlkPtr paramBlock)
  744.  ONEWORDINLINE(0xA205);
  745.  
  746.  
  747. #if GENERATING68K && !GENERATINGCFM
  748. #pragma parameter __D0 PBKillIOSync(__A0)
  749. #endif
  750. extern pascal OSErr PBKillIOSync(ParmBlkPtr paramBlock)
  751.  ONEWORDINLINE(0xA006);
  752.  
  753.  
  754. #if GENERATING68K && !GENERATINGCFM
  755. #pragma parameter __D0 PBKillIOAsync(__A0)
  756. #endif
  757. extern pascal OSErr PBKillIOAsync(ParmBlkPtr paramBlock)
  758.  ONEWORDINLINE(0xA406);
  759.  
  760.  
  761. #if GENERATING68K && !GENERATINGCFM
  762. #pragma parameter __D0 PBKillIOImmed(__A0)
  763. #endif
  764. extern pascal OSErr PBKillIOImmed(ParmBlkPtr paramBlock)
  765.  ONEWORDINLINE(0xA206);
  766.  
  767. #endif
  768. extern pascal short OpenDeskAcc(ConstStr255Param deskAccName)
  769.  ONEWORDINLINE(0xA9B6);
  770.  
  771. extern pascal void CloseDeskAcc(short refNum)
  772.  ONEWORDINLINE(0xA9B7);
  773.  
  774. #if CGLUESUPPORTED
  775. extern short opendeskacc(const char *deskAccName);
  776.  
  777. extern OSErr opendriver(const char *driverName, short *refNum);
  778.  
  779. #endif
  780. #if OLDROUTINENAMES
  781. /*
  782.     The PBxxx() routines are obsolete.  
  783.     
  784.     Use the PBxxxSync(), PBxxxAsync(), or PBxxxImmed version instead.
  785. */
  786. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  787. #define PBControl(pb, async) ((async) ? PBControlAsync(pb) : PBControlSync(pb))
  788. #define PBStatus(pb, async) ((async) ? PBStatusAsync(pb) : PBStatusSync(pb))
  789. #define PBKillIO(pb, async) ((async) ? PBKillIOAsync(pb) : PBKillIOSync(pb))
  790. #if !OLDROUTINELOCATIONS
  791. #define PBOpen(pb, async) ((async) ? PBOpenAsync(pb) : PBOpenSync(pb))
  792. #define PBClose(pb, async) ((async) ? PBCloseAsync(pb) : PBCloseSync(pb))
  793. #define PBRead(pb, async) ((async) ? PBReadAsync(pb) : PBReadSync(pb))
  794. #define PBWrite(pb, async) ((async) ? PBWriteAsync(pb) : PBWriteSync(pb))
  795. #endif
  796. #endif
  797. #endif
  798. #if FOR_SYSTEM8_PREEMPTIVE
  799. /*
  800. //////////////////////////////////////////////////////////////////////////////
  801.  System 8 Ndrv requests entry point drivers
  802. */
  803. extern OSStatus DoDeviceManagerIO(IOCommandID commandID, IOCommandContents contents, IOCommandCode code, IOCommandKind kind, KernelNotification *someTypeofNotification);
  804.  
  805. struct DeviceManagerIOIteratorData {
  806.     IOCommonInfo                     ioCI;
  807.     short                             pluginNumber;
  808.     short                             refNum;
  809.     DriverDescription                 desc;
  810. };
  811. typedef struct DeviceManagerIOIteratorData DeviceManagerIOIteratorData;
  812.  
  813. extern OSStatus DeviceManagerGetDeviceData(ItemCount requestItemCount, ItemCount *totalItemCount, DeviceManagerIOIteratorData **dataArray);
  814.  
  815. #endif
  816.  
  817. #if PRAGMA_ALIGN_SUPPORTED
  818. #pragma options align=reset
  819. #endif
  820.  
  821. #if PRAGMA_IMPORT_SUPPORTED
  822. #pragma import off
  823. #endif
  824.  
  825. #ifdef __cplusplus
  826. }
  827. #endif
  828.  
  829. #endif /* __DEVICES__ */
  830.  
  831.